<?php 
define('_VIEW_MODEL_','admin');
session_start();
$statu = $_SESSION['statu'];
require_once("../init.php");
$action   = "all";
$where    = "";
$selectnu = 0;
$selectva = "";
if(isset($page)){
		$page = intval($page);
	}else{
		$page = 1;
	}
	$stat = ($page-1)*$adminusernum;
if(!$statu){
	echo "<script>window.parent.location.href='./index.php'</script>";
}
if(isset($act)&&$act=="rank"){
	$db->Execute("update {$telper}novel set `rank`='$value'where `id` = '$id'");
}
if(isset($act)&&$act=="stat"){
	$val = $value==0?1:0;
	$db->Execute("update {$telper}novel set `state`='$val'where `id` = '$id'");
}
if(isset($act)&&$act=="searchuser"){
	if($stylename == 1){
		  $where = "where `author` = '$selectvalue'";
	}
	if($stylename == 2){
		  $where = "where `title` = '$selectvalue'";
	}
	$selectnu = $stylename;
	$selectva = $selectvalue;
}
$num = $db->GetRow("select count(id) from {$telper}novel $where");
//echo "select * from {$telper}novel $where order by rank,creattime desc limit $stat,$adminusernum";
$rs = $db->Execute("select * from {$telper}novel $where order by rank,creattime desc limit $stat,$adminusernum");
if(!empty($rs)){
	$novelinfo = $rs->GetArray();
}else{
	$novelinfo = false;
}
$pageObj = new Page($num['count(id)'],$adminusernum,$smartyObj);
$smartyObj->assign('title',$admintitle);
$smartyObj->assign('namevalue',$selectva);
$smartyObj->assign("selectstyle",$selectnu);
$smartyObj->assign("admintitle",$adminnovellist);
$smartyObj->assign("novelarray",$novelinfo);
$smartyObj->assign("act",$action);
$smartyObj->assign("novelst",$novelstyle);
$smartyObj->display("novel.tpl");
?>